
#include <stdio.h>

int main()
{
//    FILE *pf = fopen("mm.txt","w+");
//    int arr[10] = {0,1,0xffffffff,2,3,4,5,6,7,8};
//    fputs((char*)arr,pf);
//    fclose(pf);
    FILE *pf = fopen("mm.txt","w+");
    int arr[10] = {0,1,0xffffffff,2,3,4,5,6,7,8};
//    fputs((char*)arr,pf);
    fwrite((void*)arr,4,10,pf);
    rewind(pf);
    int arrCpy[10];
    fread((void*)arrCpy,4,10,pf);
    for(int i = 0; i < 10; i++)
    {
        printf("%d\n",arrCpy[i]);
    }
    fclose(pf);
}

int main1()
{
    char buf[1024] = "a\nbc\0defg";
    FILE *pfa = fopen("xx.txt","w+");
    fputs (buf,pfa);

    char readArr[1024];
    rewind(pfa);
    fgets(readArr,1024,pfa);
     printf("%s",readArr);
    fclose(pfa);

    FILE *pfb = fopen("yy.txt","wb+");
    fwrite((void*)buf,1,8,pfb);
    rewind(pfb);
    fread((void*)readArr,1,8,pfb);
    for(int i = 0; i<8;i++)
    {
        printf("%x -> %c \n",readArr[i]),readArr[i];
    }
    fclose(pfb);
//    printf("Hello World!\n");
    return 0;
}
